import { request } from '../plugins/axios.js';

// 获取商品参数列表
export function list({ cat_id, sel }) {
  return request({
    method: 'GET',
    url: `categories/${cat_id}/attributes`,
    params: { sel },
  });
}

// 添加动态参数或者静态属性
export function add({ cat_id, attr_name, attr_sel }) {
  return request({
    method: 'POST',
    url: `categories/${cat_id}/attributes`,
    data: { attr_name, attr_sel },
  });
}

// 编辑动态参数或者静态属性
export function edit({ cat_id, attr_id, ...data }) {
  return request({
    method: 'PUT',
    url: `categories/${cat_id}/attributes/${attr_id}`,
    data,
  });
}

// 删除动态参数或静态属性
export function del({ cat_id, attr_id }) {
  return request({
    method: 'DELETE',
    url: `categories/${cat_id}/attributes/${attr_id}`,
  });
}
